{% extends 'base.html' %}

{% block title %}用户登录{% endblock %}

{% block content %}
<div class="row justify-content-center">
    <div class="col-md-6">
        <div class="card shadow-sm">
            <div class="card-header bg-primary text-white">
                <h4 class="mb-0">账号登录</h4>
            </div>
            <div class="card-body">
                <form method="post">
                    {% csrf_token %}
                    <!-- 登录错误提示 -->
                    {% if form.errors %}
                    <div class="alert alert-danger" role="alert">
                        用户名或密码错误，请重新输入
                    </div>
                    {% endif %}

                    <!-- 用户名 -->
                    <div class="mb-3">
                        <label for="{{ form.username.id_for_label }}" class="form-label">用户名</label>
                        {{ form.username }}
                    </div>

                    <!-- 密码 -->
                    <div class="mb-3">
                        <label for="{{ form.password.id_for_label }}" class="form-label">密码</label>
                        {{ form.password }}
                    </div>

                    <button type="submit" class="btn btn-primary w-100">登录</button>
                </form>
                <div class="mt-3 text-center">
                    <p>没有账号？<a href="{% url 'register' %}">立即注册</a></p>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %}